home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
58189
/
58189.xpi
/
modules
/
ClientPolicy.jsm
next >
Wrap
Text File
|
2010-01-06
|
2KB
|
63 lines
/*
* This class represents the client policy, which is able to make an
* autonomous decision about a certain request.
*/
var EXPORTED_SYMBOLS = [ ];
Components.utils.import("resource://csfiremodules/CsFireCommon.jsm");
CsFire.ClientPolicy = new function() {};
/*
* This method makes a decision about a request, using the provided request
* data. The outcome is one of the values defined in the Policy class.
*/
CsFire.ClientPolicy.decide = function(data) {
var decision = { "action": CsFire.Policy.BLOCK,
"source": CsFire.Policy.SRC_CLIENT };
var crossDomain = CsFire.HttpUtils.isRequestCrossDomain(CsFire.HttpUtils.CROSSDOMAIN_RELAXED, data);
if(crossDomain) {
if(data.method == "GET" || data.method == "HEAD") {
if(data.params == null) {
if(data.user_initiated == false) {
if(data.dst_item == "favicon.ico") {
decision.action = CsFire.Policy.ACCEPT;
}
else {
decision.action = CsFire.Policy.STRIP;
decision.stripAuth = true;
decision.stripCookies = true;
}
}
else {
decision.action = CsFire.Policy.ACCEPT;
}
}
else {
decision.action = CsFire.Policy.STRIP;
decision.stripAuth = true;
decision.stripCookies = true;
}
}
else if(data.method == "POST" || data.method == "PUT" || data.method == "DELETE") {
decision.action = CsFire.Policy.STRIP;
decision.stripAuth = true;
decision.stripCookies = true;
}
else if(data.method == "OPTIONS" || data.method == "TRACE") {
decision.action = CsFire.Policy.ACCEPT;
}
else {
CsFire.Logger.warn("Unknown HTTP method: " + data.method);
decision.action = CsFire.Policy.BLOCK;
}
}
else {
decision.action = CsFire.Policy.ACCEPT;
}
return decision;
};